import 'dart:async';

import 'package:meta/meta.dart';
import 'dart:typed_data';

import '../../../sentry_flutter.dart';
import '../sentry_native_channel.dart';

/// OHOS specific native binding.
/// Currently reuses the generic MethodChannel implementation but
/// allows platform specific capability flags.
@internal
class SentryNativeOhos extends SentryNativeChannel {
  SentryNativeOhos(super.options);

  @override
  bool get supportsReplay => true;

  @override
  Future<void> captureEnvelope(
      Uint8List envelopeData, bool containsUnhandledException) {
    // OHOS 端 ETS 已同时兼容 Map 和 List 两种入参。为避免某些通道实现对二进制 Map 的序列化差异，
    // 这里改为使用位置参数（List）并将 Uint8List 转为 List<int>，提高兼容性。
    // ignore: avoid_print
    print('flutter captureEnvelope ss');
    return channel.invokeMethod(
      'captureEnvelope',
      <dynamic>[envelopeData.toList(), containsUnhandledException],
    );
  }
}
